The present invention generally relates to database management systems, and more particularly to lock management for partitioned databases.
A database is partitioned for administrative and performance purposes. A partition is defined in terms of a range of keys, either primary or secondary, to records in a table. Partitions allow a database administrator (DBA) to add, delete, or change information for a range of records in a table. For example, if some data within a partition of the table is no longer valid, the DBA can remove the partition that contains invalid data and then restore the valid data to the partition. Without partitions, the DBA would have to remove the entire table and restore the valid data, thereby making the entire database inaccessible to users. The partitions allow a user to continue to access some portions of a table while another portion of it has been removed for maintenance.
In support of concurrent access to a database, data locks are used to protect the data in individual rows, partitions, or database tables. Partition-level locking allows a user to lock a particular partition without impacting other users"" access to other partitions. Some databases include many partitions for administrative convenience and for promoting concurrent access. However, some database applications and operations require locking every partition in the database, which is known as a xe2x80x9ctable lock.xe2x80x9d
In a database having many partitions, frequent table locks may negatively impact system performance. Since every partition must be checked and locked to issue a table lock, the time required to process a table lock will depend in part on the number of partitions. Furthermore, frequent table locks will multiply the inefficiency.
A method and apparatus that addresses the aforementioned problems, as well as other related problems, are therefore desirable.
In various embodiments, the invention provides a method and apparatus for locking a database table having a plurality of partitions. Separate lock status codes are maintained for both the entire database table and for the partitions of the database table. The partition locks do not need to be updated when a lock is granted for the database table since a separate table lock status code is maintained. The separate table lock status code improves database application performance and simplifies programming of explicit lock operations.
The above summary of the present invention is not intended to describe each disclosed embodiment of the present invention. The figures and detailed description that follow provide additional example embodiments and aspects of the present invention.